package com.ali.controller;

import com.ali.common.Response;
import com.ali.config.JWTUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/auth")
public class AuthController {
    @PostMapping(value = "/login")
    public Response<String> login(@RequestBody Map<String, Object> param) {
        log.info("login：" + param);
        String username = (String) param.get("username");
        String token = JWTUtil.getToken(username, 3600);
        return Response.success(token);
    }

    @PostMapping(value = "/logout")
    public Response<String> logout(@RequestBody Map<String, Object> param) {
        log.info("logout：" + param);
        return Response.success("");
    }
}
